# -*- coding: utf-8 -*-
# @Time : 2022/4/9 20:31
# @Author : Liuqing
# @File : 14_平面化.py
# @Software : PyCharm
def spread(arg):
    ret = []
    for i in arg:
        if isinstance(i, list):
            ret.extend(i)
        else:
            ret.append(i)
    return ret


def deep_flatten(lst):
    res = []
    res.extend(spread(list(map(lambda x: deep_flatten(x) if type(x) == list else x, lst))))
    return res


if __name__ == '__main__':
    print(deep_flatten([1, [2], [[3], 4], 5]))
